<%@ page language="java" pageEncoding="UTF-8" buffer="16kb"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<%@ include file="/module/js.jsp"%>
<style>

table label.error {
    margin-left: 5px;
    width: auto;
    display: inline;
    color: red;
}
</style>	
</head>
<body>
     <form action="#" name="Form" id="Form" method="post">
	   <input type="hidden" name="token" value="${token}" />       
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="80%">
			<tr>
				<td class="table-header" colspan="2">专家组管理</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 30%"><font color="red">*</font>专家组名称：</td>
				<td class="table-contentTD" style="width: 70%"><input type="text" id="groupname" name="groupname" value="" autocomplete="off" class="inputText required" placeholder="请输入专家组名称"/>
				</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 30%"><font style="color: red;">*</font>成员：</td>
				<td style="clear:both; width:70%" class="table-contentTD">
				 <table border="0" cellpadding="0" cellspacing="0">
				 <tr>
				 <td>
				 <input autocomplete="off" class="inputText" name="searchemp" ondblclick="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"  onkeyup="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"/><font color="green">在此查找</font> <br/>
  	   				<br/><label style="color:red;">未选中:</label><br/>
  	   				<select name="fromSelect" id="fromSelect" multiple="multiple" class="inputText"  style="width:220px; height: 300px;" ondblclick="moveField('fromSelect','toSelect');">
  	   				   <c:forEach items="${employeeList}" var="employee">
  	   				   <option value="${employee.emid}">${employee.xm}</option>
  	   				   </c:forEach>
					</select>
					<select name="sourseFromSelect2" id="sourseFromSelect2" multiple="multiple" style="width: 220px; height: 150px; display: none;" >
					 <c:forEach items="${employeeList}" var="employee">
  	   				   <option value="${employee.emid}">${employee.xm}</option>
  	   				   </c:forEach>
  	    				</select>
  	    			</td>
  	    			 <td align="center" style="width: 10%">
  	   				 <input type="button" class="inputButton" onclick="moveAllField('fromSelect','toSelect');" style="width: 40px;" value=">>" />
					<br>
					 <br/>
					<input type="button" class="inputButton" onclick="moveField('fromSelect','toSelect');" style="width: 40px;" value=">" />
	 			   <br/>
	               <br/>
					<input type="button" class="inputButton"  style="width: 40px;" value="&lt" onclick="moveField('toSelect','fromSelect');"/><br/> <br/>
     				<input type="button" class="inputButton" style="width: 40px;" onclick="moveAllField('toSelect','fromSelect');"  value="&lt&lt" />
     				</td>
     			  <td style="width: 45%;bottom: 0"><br/><br/><label style="color:red;">已选中:</label><br/>
     				<select name="toSelect" id="toSelect" multiple="multiple"  class="inputText"   style="width:220px;height: 300px;" ondblclick="moveField('toSelect','fromSelect');">
					</select><span style="color: red;" id="msg02"></span>
					<input type="hidden" id="empids" name="empids" value="" />
     			 </td>
     			 </tr>
				 </table>
				 </td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 12%">备注：</td>
				<td class="table-contentTD" style="width: 21%"><textarea  id="remark" name="remark" style="width: 70%;height: 80px;" placeholder="请输入备注信息" ></textarea>
				</td>
			</tr>
		</table>
		<br />
		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<tr>
								<%--    <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId("OF_ZLTS_CLGL")%>" key="add"> --%>
			    <td><input type="button" id="btnSave" class="inputButton"
					style="text-align: center;" value="保存" /></td>
				<td><input type="button" id="btnSaveContinue" class="inputButton"
					style="text-align: center;" value="保存并新增" /></td>
			<%-- 		</kl:permission> --%>
				<td><input type="button" id="Cancel" class="inputButton"
					style="text-align: center;" value="取消" /></td>
				<td><input type="button" id="returnBut" class="inputButton"
					value="返回" style="text-align: center;" /></td>
			</tr>
		</table>
		<script>
		
			$(document).ready(function() {
				var _form=$("#Form").validate();
				$("#btnSave").click(function() {
					if(_form.form()){
						valdateReviewTeacherGroup(1); 	
					 }
				});
				
				$("#btnSaveContinue").click(function() {
					if(_form.form()){
						valdateReviewTeacherGroup(2);
					}
				});
				$("#Cancel").click(function() {
					document.Form.action ="${basePath}/teacherReviewGroup/addReviewTeacherGroupForward";
					document.Form.submit();
		 		});
				
				$("#returnBut").click(function() {
					document.Form.action ="${basePath}/teacherReviewGroup/index";
					document.Form.submit();
		 		});
				
				 if("${msg}"!=""){
				       layer.alert("${msg}", {icon: 6});
				 } 
			});
		   function valdateReviewTeacherGroup(param){
			   $("#msg02").html("");
			   var   mySelect = document.getElementById("toSelect");
			   if(mySelect.length==0){
				   $("#msg02").html("这一项必须填写.");
				   return false;
			   }else{
				   var empids="";
				   for(i=0;i<mySelect.length;i++){
					  if(i==0){
					   empids=mySelect[i].value; 
					  }else{
						empids=empids+","+mySelect[i].value;    
					  }
				   }
				   $("#empids").val(empids);
			   }
				$.ajax({
	                type: "post",
	                url: "${basePath}/teacherReviewGroup/valdateReviewTeacherGroup",
	                data: { groupname :$("#groupname").val(),groupid:-1},
	                success: function(data){
	             	   if(data==-1){
	             		  layer.alert("专家组名称不能为空", {icon: 6});
	             		  return false;
	             	   }else if(data==1){
	             		  layer.alert("专家组名称重复", {icon: 6});
	             		  return false;   
	             	   }else if(data==0){
	             		  document.Form.action ="${basePath}/teacherReviewGroup/addReviewTeacherGroup?flag="+param;
						  document.Form.submit();   
	             	   }else{ //不符合条件
	        		       layer.alert("服务器异常", {icon: 6});
	         		       return false;	  
	        		      }      
	                }
	   	   		});   
			   
			   
		   }
			
		</script>
	</form>
</body>
</html>
